// "redux": "4.0.4"
import { createStore } from "redux";

/**
 * reducer本质上就是一个普通函数
 * @param {之前仓库中的状态} state
 * @param {描述要做什么的对象} action
 */
function reducer(state, action) {
    // 返回一个新的状态
    if (action.type === 'increase') {
        return state + 1;
    } else if (action.type === 'decrease') {
        return state - 1;
    } else {
        return state;
    }
}

const store = createStore(reducer, 10);
console.log(store, '看一下');

const action = {
    type: 'increase'
}

store.getState();
console.log(store.getState());

store.dispatch(action);

store.getState();
console.log(store.getState());